<template>
	<view class="carPage">
		<view class="flexTop">
			<view class="tt">接站地点</view>
			<view class="tt">送站地点</view>
		</view>
		
		<uni-collapse accordion v-model="nowOpen" @change="changeCollapse">
			<uni-collapse-item  :border="false" name="1">
				<template v-slot:title>
					<view class="flexTop">
						<view>
							<view class="qq">  无锡新区站 </view>
						</view>
						<view>
							<view class="qq"> 博览中心A体育馆 </view>
						</view>
					</view>
				</template>
				<view class="roomList">
					<view class="room" v-for="r in carList" :key="r.id">
						<view class="ff">
							<view>
								<image class="roomCover" mode="aspectFill" :src="r.photo"></image>
							</view>
							<view style="width: calc(100% - 180rpx);">
								<view class="name"> 大巴车</view>
								<view class="flexinline"> 座位数 50  </view>
								<view class="flexinline">
									<text>可送车</text>
									<text>蓝色</text>
									<text>可接车</text>
								</view>
							</view>
						</view>
					
						<view class="carFlex">
							 <text class="price">¥30</text>
							 <view>
								  接站车辆数
								<uni-number-box @change="changecarNum" :min="0" v-model="r.num" :max="10">
								</uni-number-box>
							 </view>
						</view>
						<view class="carFlex">
							 <text class="price">¥30</text>
							 <view>
								  送站车辆数
								<uni-number-box @change="changecarNum" :min="0" v-model="r.num" :max="10">
								</uni-number-box>
							 </view>
						</view>
					</view>
				</view>
				
				
			</uni-collapse-item>
			<uni-collapse-item  :border="false" name="2">
				<template v-slot:title>
					<view class="flexTop">
						<view>
							<view class="qq"> 无锡东站 </view>
						</view>
						<view>
							<view class="qq"> 体育馆 </view>
						</view>
					</view>
				</template>
				<view class="roomList">
					<view class="room" v-for="r in carList" :key="r.id">
						<view class="ff">
							<view>
								<image class="roomCover" mode="aspectFill" :src="r.photo"></image>
							</view>
							<view style="width: calc(100% - 180rpx);">
								<view class="name"> {{r.name}} <text class="price">¥30</text></view>
								<view class="flexinline"> 座位数 50  </view>
								<view class="flexinline">
									<text>可送车</text>
									<text>蓝色</text>
									<text>可接车</text>
								</view>
								
							</view>
						</view>
						
						<view class="carFlex">
							 <text class="price">¥30</text>
							 <view>
								  接站车辆数
								<uni-number-box @change="changecarNum" :min="0" v-model="r.num" :max="10">
								</uni-number-box>
							 </view>
						</view>
						<view class="carFlex">
							 <text class="price">¥30</text>
							 <view>
								  送站车辆数
								<uni-number-box @change="changecarNum" :min="0" v-model="r.num" :max="10">
								</uni-number-box>
							 </view>
						</view>
					</view>
				</view>
				
				
			</uni-collapse-item>
		</uni-collapse>
		

		<view class="bbfix">
			<!-- 底部提交 -->
			<view class="price">
				总价：
				<text>￥{{ money }}</text>
			</view>
			<view class="subBtn" style="filter: grayscale(1);" v-if="nowOpen==''"> 去下单 </view>
			<view class="subBtn" @click="submit" v-else> 去下单 </view>
		</view>
	</view>
</template>

<script setup>
	import {
		reactive,
		toRefs,
		getCurrentInstance
	} from 'vue';
	import * as hotel from '@/common/hotel.js';
	import {
		onShow,
		onShareAppMessage,
		onShareTimeline,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import _ from 'lodash';
	const app = getApp();
	const {
		proxy
	} = getCurrentInstance();
	const data = reactive({
		range: [],
		nowOpen:'1',
		carList:[{id:0,name:'111',num:'0',price:30},{id:0,name:'222',num:'0',price:40},{id:0,name:'333',num:'0',price:50}],
		money:0
	});
	const {
		range,carList,nowOpen,money
	} = toRefs(data);
	onShow(option => {
		if (app.globalData.isLogin) {
			getList();
		} else {
			app.firstLoadCallback = () => {
				getList();
			};
		}
	})
	function getList(){
		
	}
	function changecarNum(e){
	
	}
	function changeCollapse(e){
		console.log(e)
		if(e!==nowOpen.value){
			
		}
	}
	function submit(){
		console.log(JSON.stringify(carList.value))
		const list  = encodeURIComponent(JSON.stringify(carList.value))
		let path = `/pages_hotel/car/order?carList=${list}`;
		uni.navigateTo({
			url: path
		});
		
	}
</script>

<style scoped lang="scss">
	.carPage{
		:deep(.uni-collapse-item){margin: 0;padding: 0;}
	}
	.flexTop{display: flex;
		&>view{width: 50%;text-align: center;}
		.tt{color: #1EC886;font-size: 28rpx;padding: 20rpx;}
		.qq{padding: 30rpx;font-size: 28rpx;}
	}
	.roomList {
		padding: 20rpx;
		box-sizing: border-box;
	}

	.room {
		.ff{display: flex;}
		
		position: relative;
		padding: 15rpx 0 15px;
		border-bottom: 1px solid #DCDCDC;

		.name {
			font-size: 34rpx;width: 100%;
			text{float: right;}
		}

		.orange {
			font-size: 24rpx;
		}

		.po {
			position: absolute;
			right: 0;
			bottom: 15rpx;
			display: flex;
			align-items: flex-end;
		}

		.price {
			margin-right: 10rpx;
		}
	}

	.roomCover {
		width: 160rpx;
		margin-right: 20rpx;
		height: 170rpx;
		border-radius: 15rpx;
	}
	.price{display: flex;align-items: baseline;color: #1EC886;
		text{color: #1EC886;font-size: 55rpx;}
	}
	.flexinline{display: flex;font-size: 24rpx;color: #5E5E5E;width: 100%;
	 text{margin-right: 15rpx;}
	}
	.carFlex{display: flex;font-size: 24rpx;color: #5E5E5E;width: 100%;justify-content: space-between;
		align-items: center;
		view{display: flex;align-items: center;}
		:deep(.uni-numbox){margin-left: 20rpx;}
	}
	.bbfix {
		background: #fff;
		height: 150rpx;
		display: flex;
		position: fixed;
		z-index: 89;
		width: 100%;
		bottom: 0;
		align-items: baseline;
		justify-content: space-between;
		border-top: 1rpx solid #dcdcdc;
	
		.price {
			padding-left: 20rpx;
	
			text {
				font-weight: bold;
				font-size: 45rpx;
				color: #ff8124;
			}
		}
	
		.subBtn {
			font-size: 36rpx;
			color: #ffffff;
			background: #ff8124;
			height: 120rpx;
			line-height: 100rpx;
			padding: 0 30rpx;
		}
	}
</style>